import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';

import 'dio_client.dart';
import 'net_exception.dart';

mixin DioClientInitMixin {
  final DioClient httpClient = DioClient(
      config: HttpClientConfig.init(
          // httpBaseUrl: HttpUrl.BASE_URL,
          httpBaseUrl: '',
          httpInterceptors: [
            LogInterceptor(requestBody: true, responseBody: true),
        // HttpParamsInterceptor(),
        // dioLoggerInterceptor,
        // if (Env.instance.config.env.enableLog)
        //   LogInterceptor(requestBody: true, responseBody: true),
        // statusCodeInterceptor,
      ]));
}

class NetExceptionDefault extends NetException implements Exception {
  NetExceptionDefault(super.code, {super.defaultMsg});

  @override
  String get message => _getMsg();

  String _getMsg() {
    var suffix = !kReleaseMode ? "_$code" : "";
    var tr = defaultMsg;
    if (defaultMsg.isEmpty) {
      //未找到翻译
    }
    return "$tr $suffix";
  }
}
